package com.fbli.test.common.exception;

import com.fbli.test.common.result.ResultSend;
import com.fbli.test.util.JsonUtil;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.ServletResponse;
import java.io.IOException;

@ControllerAdvice
public class myException {

    @ExceptionHandler({UnauthorizedException.class})
    public void shiroException(ServletResponse response, UnauthorizedException e) throws IOException {
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().write(JsonUtil.INSTANCE.obj2json(ResultSend.send(100003,"没有权限!",null)));
    }

}
